#include <Python.h>
#include <libdepythonize_c.h>

static PyObject *
translate_py(PyObject *self, PyObject *args)
{
  char* codigo_in;
  if (!PyArg_ParseTuple(args, "s", &codigo_in))
      return NULL;
  char* codigo_out = translate_c(codigo_in);
  PyObject *codigo_py = Py_BuildValue("s", codigo_out);
  //printf("en depythonize python:\n %s\n", codigo_out);
  free_mem(codigo_out);
  return codigo_py;
}

static PyObject *
print_tokens_py(PyObject *self, PyObject *args)
{
  char* codigo_in;
  if (!PyArg_ParseTuple(args, "s", &codigo_in))
      return NULL;
  char* codigo_out = print_tokens_c(codigo_in);
  PyObject *codigo_py = Py_BuildValue("s", codigo_out);
  //printf("en depythonize python:\n %s\n", codigo_out);
  free_mem(codigo_out);
  return codigo_py;
}

PyMethodDef methods[] = {
    {"translate_py", translate_py, METH_VARARGS, "Returns a depythonized C code"},
    {"print_tokens_py", print_tokens_py, METH_VARARGS, "Returns tokens of C code"},
    {NULL, NULL, 0, NULL}
};

PyMODINIT_FUNC 
initdepythonize()
{
    (void) Py_InitModule("depythonize", methods);
}


